<script>
import getWebSocketClient from "@/Grace6/js/ws";
// import h5PageAnimation from '@/components/h5-page-animation/';

export default {
  // mixins: [h5PageAnimation],
  onLaunch: function (options) {
    // 获取链接去掉#/   拿到uid和token
    // var url= window.location.href;

    // #ifdef APP-PLUS
    const domModule = uni.requireNativePlugin("dom");
    domModule.addRule("fontFace", {
      fontFamily: "graceuiiconfont",
      src: "url('https://at.alicdn.com/t/c/font_823462_whtuj4ktcl.ttf?t=1703075468532')",
    });
    console.log("字体加载成功");
    // #endif

    // #ifdef MP-WEIXIN
    wx.onNeedPrivacyAuthorization(function (e) {
      console.log(e);
    });
    // #endif
    // if (uni.app.checkLogin()) {
    // 	console.log(uni.app.checkLogin())
    // 	// websocket.connectSocket()

    // 	// 创建WebSocketClient实例
    // 	getWebSocketClient();
    // }
  },
  onShow: function () {
    var url = window.location.href;
    // var url ='https://www.yaozhuasocial.com/yaozhua_shequ/#/pages/my/my?accessToken=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOiIxIiwiZXhwIjoyMDY4NzIxNzA5LCJpbmZvIjoie1wibmlja05hbWVcIjpcIuaRh-eIquWumOaWuVwiLFwidGVybWluYWxcIjoxLFwidXNlcklkXCI6MSxcInVzZXJOYW1lXCI6XCLmkYfniKrlrpjmlrlcIn0ifQ.oX69C2NNqLb0DuMARt8yWjWGvoITRQ1ClOPoGyFcGRY&refreshToken=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOiIxIiwiZXhwIjoyMDY4NzIxNzA5LCJpbmZvIjoie1wibmlja05hbWVcIjpcIuaRh-eIquWumOaWuVwiLFwidGVybWluYWxcIjoxLFwidXNlcklkXCI6MSxcInVzZXJOYW1lXCI6XCLmkYfniKrlrpjmlrlcIn0ifQ.8DQJZJtvCAhNEcGVI96cnDFdI-B_jiiZJnRffssgCLI&token=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3FIFjbzadVvhdunhVcWoeOnL7sjNt6dOFUMsEqAECzUj/qnIw3OhxiIv+Cq9jKxPikbEwAcin4FzENLfsPwYyMe24IwRI3gHtcbVqChG5bzedyA9AmYk+4s9d8qPow8Dh8HO1omQcfGP0Nu85JlDiAyF8KETDs1kYD1qwE/P/wwIDAQAB&token1=wvumjv5akmjn7rvwomottwjlcc49o3xf&token2=69b24b36ef2e5e4d&token3=b333388f15744753a9b77541735a3b52&userId=0f56366a8054fe012b04ed9b2e3d1201'
    var url1 = url.split("#/");

    var params = new URLSearchParams(new URL(url1).search);
    var token = params.get("accessToken");
    var userId = params.get("userId");

    uni.setStorageSync("token", token);
    uni.setStorageSync("parentId", 1);
    uni.setStorageSync("userId", userId);

    var imData = url;
    let index = imData.lastIndexOf("?");
    imData = imData.substring(index + 1, imData.length);
    uni.setStorageSync("imData", imData);

    // uni.setStorageSync(
    //   "token",
    //   "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOiIxIiwiZXhwIjoyMDY5MDc2NjE0LCJpbmZvIjoie1wibmlja05hbWVcIjpcIuaRh-eIquWumOaWuVwiLFwidGVybWluYWxcIjoxLFwidXNlcklkXCI6MSxcInVzZXJOYW1lXCI6XCLmkYfniKrlrpjmlrlcIn0ifQ.DxfaTY7AONQ-WQAeud4_0gQM3NSn_vG0pup_OCHDAzw&refreshToken=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOiIxIiwiZXhwIjoyMDY5MDc2NjE0LCJpbmZvIjoie1wibmlja05hbWVcIjpcIuaRh-eIquWumOaWuVwiLFwidGVybWluYWxcIjoxLFwidXNlcklkXCI6MSxcInVzZXJOYW1lXCI6XCLmkYfniKrlrpjmlrlcIn0ifQ.eM8g9BMuVpWaiUGdczkmbaRMKSxQ9-QJlwom59qF3nE&token=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQD6QpsYUHWMVSgR7JpxDMp78XCYseb5oSZkfqmUXu02KDLPpKPMOgYvBIyRCiqj5kViiqXbkZNyLi8mK85alZMkmlfoZbqkWw5ObIZ4DYi/WqsjT9eyvcmbwpp9yVnLV2RAh4mBVglj7cO42WnywqPFx3NnkK/QHZqlXOEhNO/tBwIDAQAB&token1=v4hk2n8anl0jk69l568eibt6fbu7mhg4&token2=d0a49c835078217d&token3=105e2511dd43473ca75054920183504a&userId=0f56366a8054fe012b04ed9b2e3d1201",
    // );
    // uni.setStorageSync("parentId", 1);
    // uni.setStorageSync("userId", "08325cbcaee44a8197d18af3e89b47fb");
  },
  onHide: function () {},
  methods: {
    // getInfo(value) {
    //   console.log("value", value);
    //   uni.setStorageSync("loginInfo", value);
    //   uni.setStorageSync("token", value.token);
    //   uni.setStorageSync("userId", value.userId);
    // },
  },
};
</script>
<!-- #ifndef APP-NVUE -->
<style lang="scss">
/* 加载框架核心样式 */
@import "./Grace6/css/grace.scss";
/* 加载深色模式适配样式 */
@import "./Grace6/css/graceDark.scss";
/* 加载自定义样式 */
@import "./custom/custom.scss";

page {
  background: #f8f8f8;
}

view,
scroll-view,
swiper,
swiper-item,
cover-view,
cover-image,
icon,
text,
rich-text,
progress,
button,
checkbox,
form,
input,
label,
radio,
slider,
switch,
textarea,
navigator,
audio,
camera,
image,
video {
  box-sizing: border-box;
}
</style>
<!-- #endif -->
<!-- #ifdef APP-NVUE -->
<style lang="scss">
/* 加载框架核心样式 */
@import "./Grace6/css/grace.scss";
/* 加载自定义样式 */
@import "./custom/custom.scss";

.gui-icons {
  font-family: graceuiiconfont;
  font-style: normal;
}

.gui-header {
  background: white;
}
</style>
<!-- #endif -->
